import { _decorator, Component, Node } from 'cc';
import { joyStick } from './joyStick';
const { ccclass, property } = _decorator;

@ccclass('player')
export class player extends Component {
  @property(joyStick) joyStickScript: joyStick = null;

  moveSpeed: number = 150

  start() {

  }

  update(deltaTime: number) {
    const joyDir = this.joyStickScript.getOutV2();
    const dir = joyDir.normalize();
    const x = this.node.position.x
    const y = this.node.position.y
    const nx = x + dir.x * deltaTime * this.moveSpeed
    const ny = y + dir.y * deltaTime * this.moveSpeed
    this.node.setPosition(nx, ny)
  }
}


